<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'user-add', //页面标示
    'pagename' => '新建群组', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/fuelux/fuelux','content/combodate/moment.min','content/combodate/combodate','content/calendar'),
    'head' => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<section id="content">
  <section class="main padder">
    <div class="clearfix">
      <h4><i class="fa fa-edit"></i><?php echo trim($Document['pagename'],'_');?></h4>
    </div>
    <div class="row">
      <div class="col-sm-12">
        <section class="panel">
          <div class="panel-body">
            <form class="form-horizontal" method="post" id="groupForm">
              <div class="form-group">
                <label class="col-sm-1 control-label">要创建的群组名</label>
                <div class="col-sm-3">
                  <input type="text" name="groupname" id="groupname" placeholder="群组名" class="form-control" value="" />
                  <span class="help-block">帐户长度为2-30个字符</span></div>
              </div>
             <div class="form-group">
                <label class="col-sm-1 control-label">群组分类</label>
                <div class="col-lg-2">
                  <select name="fieldid" id="fieldid" class="form-control" style="display:inline-block;">
                   <?php
				   foreach($profieldlist as $key=>$val){
				   ?>
                    <option value="<?php echo $val['fieldid'];?>"><?php echo $val['title'];?></option>
                    <?php
				   }
				   ?>
                  </select>
                  <br/><br/>
                  <a href="<?php echo U('wxgroup/field_add');?>">创建固定分组</a>
                </div>
              </div>

              <div class="form-group">
                <div class="col-sm-9 col-lg-offset-1">
                  <div class="col-sm-1">
                    <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
                  </div>
                  <div class="col-md-offset-2">
                    <button type="button" class="btn btn-white">取消</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<!--主体 结束--> 
<script>

$(function(){
	var groupid=$.trim($("#groupid").val());
	$('#groupForm').submit(function(){
		var groupname=$.trim($("#groupname").val());
		var isOk=true;
		if (!groupname){
			Msg.error('群组名不能为空');
			resetSubmit("#sub-ok",'保存');
			return false;
		}
		Msg.loading();
		  $.post('<?php echo U('wxgroup/add');?>',$(this).serialize(),function(result){
			  Msg.hide();
			  resetSubmit("#sub-ok",'保存');
			  if (result.status==1){
				Msg.ok('添加成功',function(){
					document.location='<?php echo U('wxgroup/index');?>';	
				},3000);  
			}else{
				Msg.error(result.info);
			}
		  },'json');
		  //});
		  return false;
	})
	$("#groupid").change(function(){
		groupid=$(this).val();
		switch(groupid){
			case '1':case '2':case '6':
			$("#show-areazone").hide();
			$("#show-worker-info").hide();
			break;
			default:
			$("#show-areazone").show();
			$("#show-worker-info").show();
		}
	});
	$(".search-areazone").click(function(){
		var t=$(this).attr("rel");
		$("#ztitle").val('');
		$("#zid").val('');
		return false;
	})
	$("#select-areazone").click(function(){
		$(this).attr('href','<?php echo U('areazone/search',array(),true);?>');
	})
})
</script>
<?php
include getTpl('footer', 'public');
?>